﻿// 大气监测，各常量定义内容
function PollutantPlotLines() {
    this.colorArray = ["#00E400", "#FFFF00", "#FF7E00", "#FF0000", "#99004C", "#7E0023"];
    //this.colorArray = ["#70CA2A", "#EDCC23", "#FAA82C", "#F52603", "#89217D", "#6F102D"];
    this.levelArray = ["一级", "二级", "三级", "四级", "五级", "六级"];
    this.pollutantLevelArray = ["优", "良", "轻度污染", "中度污染", "重度污染", "严重污染"]
    this.valueArray = [];
    this.plotLines = [];
    this.valueArrayDic = {
        hour: {
            AQI: [50, 100, 150, 200, 300],
            SO2: [150, 500, 650, 800],
            NO2: [100, 200, 700, 1200, 2340, 3090],
            CO: [5, 10, 35, 60, 90, 120],
            O3: [160, 200, 300, 400, 800, 1000],
            PM10: [50, 150, 250, 350, 420, 500],
            PM2_5: [35, 75, 115, 150, 250, 350]
        },
        day: {
            AQI: [50, 100, 150, 200, 300],
            SO2: [50, 150, 475, 800, 1600, 2100],
            NO2: [40, 80, 180, 280, 565, 750],
            CO: [2, 4, 14, 24, 36, 48],
            O3: [160, 200, 300, 400, 800, 1000],
            O3_8H: [100, 160, 215, 265, 800],
            PM10: [50, 150, 250, 350, 420, 500],
            PM2_5: [35, 75, 115, 150, 250, 350]
        },
        daily: {
            'AQI': [50.1, 100.1, 150.1, 200.1, 300.1],
            'SO2': [50.1, 150.1, 475.1, 800.1, 1600.1],
            'NO2': [40.1, 80.1, 180.1, 280.1, 565.1],
            'CO': [2.001, 4.001, 14.001, 24.001, 36.001],
            'O3': [160.1, 200.1, 300.1, 400.1, 800.1],
            'O3_8H': [100.1, 160.1, 215.1, 265.1, 800.1],
            'PM10': [50.1, 150.1, 250.1, 350.1, 420.1],
            'PM2.5': [35.1, 75.1, 115.1, 150.1, 250.1]
        }
    };
    this.GetPlotLines = function (pollutant, type) {
        this.valueArray = this.valueArrayDic[type][pollutant];
        this.plotLines = [];
        for (var i = 0; i < this.valueArray.length; i++) {
            this.plotLines.push({
                color: this.colorArray[i],
                width: 3,
                value: this.valueArray[i],
                pollutantLevel: this.pollutantLevelArray[i],
                label: {
                    text: this.levelArray[i] + "标准限值：" + this.valueArray[i],
                    align: 'left'
                }
            });
        }
        return this.plotLines;
    }
    this.GetColorByPollutantValue = function (pollutant, type, pollutantValue) {
        this.valueArray = this.valueArrayDic[type][pollutant];
        var len = this.valueArray.length;
        if (type != "AQI") {
            len = this.valueArray.length - 1;
        }
        for (var i = 0; i < len; i++) {
            if (pollutantValue <= this.valueArray[i]) {
                return this.colorArray[i];
            }
            else if (pollutantValue > this.valueArray[len - 1]) {
                return this.colorArray[len];
            }
        }
    }
}